package platapi

import (
	"dta-apk/global"
	"dta-apk/huawei"
	"dta-apk/oppo"
	"dta-apk/vivo"
	"dta-apk/xiaomi"
)

const (
	Vivo   = "vivo"
	Oppo   = "oppo"
	Xiaomi = "xiaomi"
	Meizu  = "MEIZU"
	Huawei = "huawei"
)

type PlatApi interface {
	// 获取应用详情
	GetAppDetails(packageName string)
}

type Plat struct {
	// 平台类型
	Plat string
}

// 获取指定平台的应用详情
func (p Plat) GetAppDetails(packageName string) interface{} {
	switch p.Plat {
	case Vivo:
		appInfo, res := vivo.GetAppDetails(packageName)
		if res {
			return appInfo
		}
	case Oppo:
		appInfo, res := oppo.GetAppDetails(packageName, "")
		if res {
			return appInfo
		}
	case Xiaomi:
		appInfo, res := xiaomi.GetAppDetails(packageName, global.Config.App.XiaoMi.UserName)
		if res {
			return appInfo
		}
	case Meizu:
	case Huawei:
		appInfo, res := huawei.GetAppDetails(packageName)
		if res {
			return appInfo.AppInfo
		}
	default:

	}
	return nil
}
